﻿Imports System.Windows.Forms
Imports System.Data.OleDb
Imports MikroMagazaObject

Public Class Frm_Main

    Private WithEvents bgworker As New System.ComponentModel.BackgroundWorker
    Private WithEvents bgworker2 As New System.ComponentModel.BackgroundWorker
    Public Shared Degisim_Tarihi As DateTime

    Private Sub dowrok(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgworker.DoWork
        CompactDB()
    End Sub

    Private Sub complete(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgworker.RunWorkerCompleted
        'BarStaticItem1.Caption = "İşlem Tamamlandı"
    End Sub


    Private Sub report2(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgworker2.ProgressChanged
        'Select Case e.ProgressPercentage
        '    Case 1
        '        BarStaticItem1.Caption = "Günlük Kur Bilgilerini Aktarıyor Lütfen Bekleyiniz..."
        '    Case 2
        '        BarStaticItem1.Caption = "Değişen Stok Kayıtlarını Aktarıyor Lütfen Bekleyiniz..."
        '    Case 3
        '        BarStaticItem1.Caption = "Stok Kayıtlarını Aktarıyor Lütfen Bekleyiniz..."
        '    Case 4
        '        BarStaticItem1.Caption = "Stok Depo Kayıtları Aktarıyor Lütfen Bekleyiniz..."
        '    Case 5
        '        BarStaticItem1.Caption = "Stok Barkod Kayıtlarını Aktarıyor Lütfen Bekleyiniz..."
        'End Select
    End Sub
    Private dsx As New DataSet
    Private Sub dowrok2(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgworker2.DoWork
        If dsx.Tables.Contains("HISTORY") = True Then dsx.Tables.Remove("HISTORY")
        If dsx.Tables.Contains("KURLAR") = True Then dsx.Tables.Remove("KURLAR")
        If dsx.Tables.Contains("STOK") = True Then dsx.Tables.Remove("STOK")
        If dsx.Tables.Contains("STOKDEPO") = True Then dsx.Tables.Remove("STOKDEPO")
        If dsx.Tables.Contains("BARKOD") = True Then dsx.Tables.Remove("BARKOD")
        If dsx.Tables.Contains("CARI") = True Then dsx.Tables.Remove("CARI")

        Dim cls As New Cls_Database
        UzakServis.Timeout = 99999
        UzakServis.Url = Servis_Url


        If CalismaSekli = CalismaTipi.Dosya Then
            bgworker2.ReportProgress(50)
            Dim dt() As DataTable
            dt = cls.GeniusRead()

            If dt.Length > 0 Then
                dt(0).TableName = "STOK"
                dt(1).TableName = "HISTORY"
                dt(2).TableName = "BARKOD"
                dsx.Tables.AddRange(dt)
            End If
            bgworker2.ReportProgress(100)
            'ElseIf CalismaSekli = CalismaTipi.GeniusOpen Then
            '    bgworker2.ReportProgress(50)
            '    Dim dt() As DataTable
            '    dt = cls.SurePos5000()

            '    If Not dt(0) Is Nothing And Not dt(1) Is Nothing And Not dt(2) Is Nothing Then
            '        dt(0).TableName = "STOK"
            '        dt(1).TableName = "HISTORY"
            '        dt(2).TableName = "BARKOD"
            '        dsx.Tables.AddRange(dt)
            '    End If
            '    bgworker2.ReportProgress(100)
        Else
            'Dim tarih As DateTime = DateAdd(DateInterval.Day, -1, Now)
            'Dim str_tarih As String = Degisim_Tarihi.Year & "-" & Degisim_Tarihi.Month & "-" & Degisim_Tarihi.Day & " 00:00:00"
            bgworker2.ReportProgress(1)

            cls.Zaman = New DateTime(Degisim_Tarihi.Year, Degisim_Tarihi.Month, Degisim_Tarihi.Day, 0, 0, 0)
            If ProgramTipi = 0 Then
                cls._ProgramID = Cls_Database.Program.MikroV10
            Else
                cls._ProgramID = Cls_Database.Program.MikroV12
            End If

            bgworker2.ReportProgress(1)
            Dim dtkur As New DataTable
            cls._Bilgi = Cls_Database.Tip.Kurlar
            dtkur = cls.GetData
            dtkur.TableName = "KURLAR"


            bgworker2.ReportProgress(2)
            Dim dt As New DataTable
            'dt = UzakServis.Stok_List(Sql_Server, Database_Name, 0, str_tarih, 2, "001").Tables(0).Copy
            cls._Bilgi = Cls_Database.Tip.History
            dt = cls.GetData
            dt.TableName = "HISTORY"


            bgworker2.ReportProgress(3)
            Dim dt2 As New DataTable
            'dt2 = UzakServis.Stok_List(Sql_Server, Database_Name, 0, str_tarih, 2, "001").Tables(0).Copy
            cls._Bilgi = Cls_Database.Tip.StokBilgisi
            dt2 = cls.GetData
            dt2.TableName = "STOK"


            bgworker2.ReportProgress(4)
            Dim dt3 As New DataTable
            'dt3 = UzakServis.StokDepo_List(Sql_Server, Database_Name, 0, str_tarih, "001").Tables(0).Copy
            cls._Bilgi = Cls_Database.Tip.StokDepo
            dt3 = cls.GetData
            dt3.TableName = "STOKDEPO"


            bgworker2.ReportProgress(5)
            Dim dt4 As New DataTable
            'dt4 = UzakServis.Barkod_List(Sql_Server, Database_Name, 0, str_tarih, "001").Tables(0).Copy
            cls._Bilgi = Cls_Database.Tip.Barkod
            dt4 = cls.GetData
            dt4.TableName = "BARKOD"

            bgworker2.ReportProgress(6)
            Dim dt5 As New DataTable
            cls._Bilgi = Cls_Database.Tip.Cari
            dt5 = cls.GetData
            dt5.TableName = "CARI"


            dsx.Tables.Add(dt)
            dsx.Tables.Add(dt2)
            dsx.Tables.Add(dt3)
            dsx.Tables.Add(dt4)
            dsx.Tables.Add(dtkur)
            dsx.Tables.Add(dt5)
        End If
    End Sub
    Private Sub complete2(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgworker2.RunWorkerCompleted
        'BarStaticItem1.Caption = "İşlem Tamamlanıyor...."
        Dim halk As Integer = GunKontrol()
        Dim halkgunu As Boolean
        If halk <> Depo_Kod Then
            halkgunu = True
        Else
            halkgunu = False
        End If
        Dim frm As New Frm_Update(dsx, Depo_Kod, halk, halkgunu)
        frm.WindowState = FormWindowState.Normal
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.ShowDialog(Me)

        Dim count As Integer
        For i As Integer = 0 To dsx.Tables.Count - 1
            count += dsx.Tables(i).Rows.Count
        Next

        Dim tarih1 As String = Now.Year & "-" & Now.Month & "-" & Now.Day & " " & Now.Hour & ":" & Now.Minute & ":" & Now.Second

        'Try
        '    'CREATE TABLE [dbo].[SMARTOFFICE_AKTARIM_BILGISI](
        '    '	[tarih] [datetime] NULL,
        '    '	[depo_no] [int] NULL,
        '    '	[kayit_sayisi] [int] NULL,
        '    '   [islem_tipi] [tinyint] null
        '    ') ON [PRIMARY]
        '    If frm.HataVerdi = False Then
        '        UzakServis.Url = Servis_Url
        '        UzakServis.FillDataToString(Sql_Server, Database_Name, String.Format("exec sp_executesql N'INSERT INTO SMARTOFFICE_AKTARIM_BILGISI  (tarih, depo_no, kayit_sayisi,islem_tipi)  VALUES     (CONVERT(DATETIME, ''{0}'', 102), {1}, {2},0)'", tarih1, Depo_Kod, count))
        '    End If
        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try

        'BarStaticItem1.Caption = "İşlem Tamamlandı"
    End Sub

    Private Sub Frm_Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error Resume Next

        Dim acik As Integer = 0
        For Each p As Process In Process.GetProcesses()
            If p.ProcessName = "MikroMagaza" Then
                acik += 1
                If acik = 2 Then
                    MsgBox("Mikro Mağaza Modulü zaten çalışıyor")
                    Application.Exit()
                End If
            End If
        Next
        'BarStaticItem1.Caption = "Database Sıkıştırılıyor... Lütfen bekleyiniz"
        Ayar_Oku()

        Dim devam As Boolean = True
        If ProgramTipi = ProgramTipleri.MikroV15 And Database_Name.IndexOf("V15") = -1 Then
            devam = False
        ElseIf ProgramTipi = ProgramTipleri.MikroV14 And Database_Name.IndexOf("V14") = -1 Then
            devam = False
        ElseIf ProgramTipi = ProgramTipleri.MikroV12 And Database_Name.IndexOf("V12") = -1 Then
            devam = False
        ElseIf ProgramTipi = ProgramTipleri.MikroV10 And Database_Name.IndexOf("V10") = -1 Then
            devam = False
        End If

        If devam = False Then
            MsgBox("Program tipiniz uyumsuz ayarlarınızı düzeltiniz !")
            Dim frm As New Frm_Parametre
            frm.ShowDialog()
            Me.Close()
            System.Environment.Exit(Environment.ExitCode)
        End If


        'If ProgramTipi = ProgramTipleri.MikroV15 Then
        '    BarSubItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        '    BarSubItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        '    BarSubItem3.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        'End If

        Dim lic As New Security(Sql_Server, Database_Name)

        Hafiza.Ctor.Set("SRV", Sql_Server)
        Hafiza.Ctor.Set("DB", Database_Name)

        bgworker.RunWorkerAsync()

        If Not otoSendTime Is Nothing Then
            Timer1.Interval = 1000
            Timer1.Enabled = True
            Timer1.Start()
        End If
    End Sub
    Private Sub BarButtonItem2_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        BilgiAl()
    End Sub
    Private Sub BilgiAl()
        Try
            My.Forms.Frm_Tarihgir.StartPosition = FormStartPosition.CenterScreen
            If My.Forms.Frm_Tarihgir.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then

                Windows.Forms.Cursor.Current = Cursors.WaitCursor

                bgworker2.WorkerReportsProgress = True
                bgworker2.RunWorkerAsync()

                Windows.Forms.Cursor.Current = Cursors.Default
            End If

        Catch ex As Exception
            Windows.Forms.Cursor.Current = Cursors.Default
        End Try
    End Sub

    Private Sub BarButtonItem3_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        KasayaBilgiGonder()
    End Sub
    Private Sub KasayaBilgiGonder()
        Dim hatali As Boolean
        Dim count As Integer
        If Kasa_Tipi = KasaTipi.NCR Then
            Dim frm As New Frm_CashSend(Kasa_yolu, Depo_Kod)
            frm.StartPosition = FormStartPosition.CenterScreen
            frm.WindowState = FormWindowState.Normal
            frm.ShowDialog(Me)
            count = frm.GonderilenKayitSayisi
            hatali = frm.HataVerdi
        ElseIf Kasa_Tipi = KasaTipi.Genius Then
            Dim frm As New Frm_Genius_Send(Kasa_yolu, Depo_Kod)
            frm.StartPosition = FormStartPosition.CenterScreen
            frm.WindowState = FormWindowState.Normal
            frm.ShowDialog(Me)
            count = frm.GonderilenKayitSayisi
            hatali = frm.HataVerdi
        ElseIf Kasa_Tipi = KasaTipi.Inter Then
            Dim frm As New FrmInterSend(Kasa_yolu, Depo_Kod, Kasa_Kod)
            frm.StartPosition = FormStartPosition.CenterScreen
            frm.WindowState = FormWindowState.Normal
            frm.ShowDialog(Me)
            count = frm.GonderilenKayitSayisi
            hatali = frm.HataVerdi
        ElseIf Kasa_Tipi = KasaTipi.Wincor Then
            Dim frm As New frmSiemensGonderim(Cnn_String, Kasa_yolu & "\POOLPLU.DAT", Depo_Kod, KdvSiralamasi)
            frm.ShowDialog(Me)
        End If

        'Try
        '    If hatali = False Then
        '        UzakServis.Url = Servis_Url
        '        UzakServis.FillDataToString(Sql_Server, Database_Name, String.Format("exec sp_executesql N'INSERT INTO SMARTOFFICE_AKTARIM_BILGISI  (tarih, depo_no, kayit_sayisi,islem_tipi)  VALUES     (CONVERT(DATETIME, ''{0}'', 102), {1}, {2},1)'", Now.Year & "-" & Now.Month & "-" & Now.Day & " " & Now.Hour & ":" & Now.Minute & ":" & Now.Second, Depo_Kod, count))
        '    End If
        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try
    End Sub

    Private Sub BarButtonItem4_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        TeraziyeBilgiGonder()
    End Sub

    Private Sub TeraziyeBilgiGonder()
        Dim frm As Frm_Scale_Send
        If TeraziTipi = TeraziTip.ishida Then
            frm = New Frm_Scale_Send(Terazi_Yolu, Depo_Kod, Frm_Scale_Send.TeraziTip.ishida)
        ElseIf TeraziTipi = TeraziTip.cas Then
            frm = New Frm_Scale_Send(Terazi_Yolu, Depo_Kod, Frm_Scale_Send.TeraziTip.cas)
        ElseIf TeraziTipi = TeraziTip.CASLP500 Then
            frm = New Frm_Scale_Send(Terazi_Yolu, Depo_Kod, Frm_Scale_Send.TeraziTip.CASLP500)
        ElseIf TeraziTipi = TeraziTip.casLp1 Then
            frm = New Frm_Scale_Send(Terazi_Yolu, Depo_Kod, Frm_Scale_Send.TeraziTip.casLp1)
        Else
            frm = New Frm_Scale_Send(Terazi_Yolu, Depo_Kod, Frm_Scale_Send.TeraziTip.DigiSM300)
        End If
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.WindowState = FormWindowState.Normal
        frm.ShowDialog(Me)

        'Try
        '    If frm.HataVerdi = False Then
        '        UzakServis.Url = Servis_Url
        '        UzakServis.FillDataToString(Sql_Server, Database_Name, String.Format("exec sp_executesql N'INSERT INTO SMARTOFFICE_AKTARIM_BILGISI  (tarih, depo_no, kayit_sayisi,islem_tipi)  VALUES     (CONVERT(DATETIME, ''{0}'', 102), {1}, {2},2)'", Now.Year & "-" & Now.Month & "-" & Now.Day & " " & Now.Hour & ":" & Now.Minute & ":" & Now.Second, Depo_Kod, frm.GonderilenKayitSayisi))
        '    End If
        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try

    End Sub

    'Private Sub BarButtonItem5_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
    '    EtiketBasim()
    'End Sub
    Private Sub EtiketBasim(ByVal fiyat As Boolean)
        Dim frm As New Frm_Etiket()
        frm.FiyatDegisikligiEvragi = fiyat
        frm._Depo_No = Depo_Kod
        frm.exePath = Application.StartupPath
        frm._Temp_etk_file_path = Application.StartupPath & "\temp.etk"
        frm._Etiket_Yol = Yazici_Yolu
        frm._Yazdirma_Miktari = Etiket_Miktari
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.WindowState = FormWindowState.Normal
        frm.Show()
    End Sub
    Private Sub BarButtonItem7_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        SatisGonder()
    End Sub
    Private Sub SatisGonder(Optional ByVal autoSend As Boolean = False)
        Dim frm As New FrmSaleSend(autoSend)
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.WindowState = FormWindowState.Normal
        frm.ShowDialog(Me)
    End Sub
    Private Sub BarButtonItem8_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        Ayarlar()
    End Sub
    Private Sub Ayarlar()
        Dim dlg As New frmLogin
        If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Dim frm As New Frm_Parametre
            frm.StartPosition = FormStartPosition.CenterScreen
            frm.WindowState = FormWindowState.Normal
            frm.ShowDialog(Me)
        Else
            MsgBox("Yönetici Şifresi ile giriş yapabilirsiniz !")
        End If
    End Sub
    Private Sub BarButtonItem10_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        Dim frm As New FrmSifre
        If frm.ShowDialog(Me) = Windows.Forms.DialogResult.Abort Then
            Application.Exit()
        End If
    End Sub

    Private Sub BarButtonItem11_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        SatisRaporu()
    End Sub
    Private Sub SatisRaporu()
        Dim frm As New FrmSatisRaporu
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.WindowState = FormWindowState.Normal
        frm.ShowDialog(Me)
    End Sub

    Private Sub BarButtonItem12_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        Dim frm As New frmSiparisTahmin
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.WindowState = FormWindowState.Normal
        frm.ShowDialog(Me)
    End Sub
    Private Sub BarButtonItem18_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        SatisRaporu()
    End Sub
    Private Sub BarButtonItem19_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        Dim frm As New frmRapor
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.WindowState = FormWindowState.Normal
        frm.ShowDialog(Me)
    End Sub

    Private Sub BarButtonItem7_ItemClick_1(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem7.ItemClick
        Ayarlar()
    End Sub

    Private Sub btnBilgiAl_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnBilgiAl.ItemClick
        BilgiAl()
    End Sub

    Private Sub btnBilgiGonder_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnBilgiGonder.ItemClick
        SatisGonder()
    End Sub

    Private Sub btnKasaGonder_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnKasaGonder.ItemClick
        KasayaBilgiGonder()
    End Sub

    Private Sub btnTeraziGonder_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnTeraziGonder.ItemClick
        TeraziyeBilgiGonder()
    End Sub

    Private Sub btnEtiketBasimi_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEtiketBasimi.ItemClick
        EtiketBasim(False)
    End Sub

    Private Sub BtnEtiketTanimlari_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BtnEtiketTanimlari.ItemClick
        Dim frm As New frmEtiketParametreleri
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.WindowState = FormWindowState.Normal
        frm.Show()
    End Sub

    Private Sub btnAnlikRapor_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnAnlikRapor.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.AnlikSatisRaporu
        rpr.Show(Me)
    End Sub

    Private Sub DemoClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        MsgBox("Kısıtlı Kullanım kopyasıdır !")
    End Sub

    Private Sub btnCariGonder_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCariGonder.ItemClick
        Dim frm As New frmCariSend
        frm.PosgenelPath = Kasa_yolu & "\POSGENEL"
        frm.PoskonPath = Kasa_yolu & "\POSKON"
        frm.CnnString = Cnn_String
        frm.KasaSayisi = Kasa_Kod
        frm.ShowDialog()
    End Sub

    Private Sub btnKasiyer_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnKasiyer.ItemClick
        Dim frm As New frmKasiyer
        frm.PosgenelPath = Kasa_yolu & "\POSGENEL"
        frm.PoskonPath = Kasa_yolu & "\POSKON"
        frm.KasaSayisi = Kasa_Kod
        frm.ShowDialog()
    End Sub

    Private Sub btnPromosyon_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnPromosyon.ItemClick
        Try
            Cursor.Current = Cursors.WaitCursor
            Dim prmbyt() As Byte = UzakServis.DownloadPromoDat("PROMO.DAT")
            Dim noprmbyt() As Byte = UzakServis.DownloadPromoDat("NOPROMO.DAT")
            Dim frm As New frmPromoTrn
            frm.KasaSayisi = Kasa_Kod
            frm.KasaYol = Kasa_yolu
            frm.PromoData = prmbyt
            frm.NoPromoData = noprmbyt
            frm.ShowDialog()
        Catch ex As Exception

        Finally
            Cursor.Current = Cursors.Default
        End Try


    End Sub

    Private Sub btnGunlukCiro_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnGunlukCiro.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.GunlukSatisRaporu
        rpr.Show(Me)
    End Sub

    Private Sub btnAylikCiro_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnAylikCiro.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.AylikSatisRaporu
        rpr.Show(Me)
    End Sub

    Private Sub btnEncok100Urun_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEncok100Urun.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.EncokSatan100Raporu
        rpr.Show(Me)
    End Sub

    Private Sub btnAnagrupSatis_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnAnagrupSatis.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.AnaGrupBazindaCiroRaporu
        rpr.Show(Me)
    End Sub

    Private Sub btnAltGrupSatis_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnAltGrupSatis.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.AltGrupBazindaCiroRaporu
        rpr.Show(Me)
    End Sub

    Private Sub btnReyonSatis_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReyonSatis.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.ReyonBazindaCiroRaporu
        rpr.Show(Me)
    End Sub

    Private Sub BarButtonItem1_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
        If Kasa_Tipi = KasaTipi.Genius Then
            Dim frm As New frmGeniusSatisAktarim(False)
            frm.MagazaNo = Depo_Kod
            frm.SrmMerkezi = ""
            frm.OpaPath = Opa_Yol
            frm.KasaCnn = Cnn_String
            frm.KdvSiralamasi = KdvSiralamasi
            frm.ShowDialog(Me)
        ElseIf Kasa_Tipi = KasaTipi.Inter Then
            Dim frm As New frmGeniusSatisAktarim(True)
            frm.MagazaNo = Depo_Kod
            frm.SrmMerkezi = ""
            frm.OpaPath = Opa_Yol
            frm.KasaCnn = Cnn_String
            frm.KdvSiralamasi = KdvSiralamasi
            frm.ShowDialog(Me)
        Else
            MsgBox("Üzgünüz Lütfen satıcınızla görüşün !")
        End If

    End Sub

    Private Sub btnFiyat_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnFiyat.ItemClick
        EtiketBasim(True)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim saat As Integer = otoSendTime.Split(":")(0)
        Dim dakika As Integer = otoSendTime.Split(":")(1)

        If Now.Hour = saat And Now.Minute = dakika Then
            Timer1.Enabled = False
            SatisGonder(True)
        End If
    End Sub

    Private Sub btnAlisIrsaliye_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnAlisIrsaliye.ItemClick
        Dim frm As New frmEvrak
        frm.EvrakTipi = EvrakTipleri.AlisIrsaliyesi
        frm.ShowDialog()
    End Sub

    Private Sub btnAlisFatura_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnAlisFatura.ItemClick
        Dim frm As New frmEvrak
        frm.EvrakTipi = EvrakTipleri.AlisFaturasi
        frm.ShowDialog()
    End Sub

    Private Sub btnDepoSevk_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDepoSevk.ItemClick
        Dim frm As New frmEvrak
        frm.EvrakTipi = EvrakTipleri.DepoSevk
        frm.ShowDialog()
    End Sub

    Private Sub btnVerilenSiparis_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnVerilenSiparis.ItemClick
        Dim frm As New frmEvrak
        frm.EvrakTipi = EvrakTipleri.VerilenSiparis
        frm.ShowDialog()
    End Sub

    Private Sub Frm_Main_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        Application.Exit()
        'Environment.Exit(Environment.ExitCode)
    End Sub

    Private Sub BarButtonItem2_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
        Dim rpr As New MikroMagazaObject.frmReports
        rpr.Path = Kasa_yolu
        rpr.CnnString = Cnn_String
        rpr.KdvSiralamasi = KdvSiralamasi
        rpr.RaporTipi = MikroMagazaObject.ReportTypes.UrunSatisRaporu
        rpr.Show(Me)
    End Sub
End Class
